﻿namespace Yom.WebService
{
    using System;
    using System.Collections.Generic;
    using Yom.Common;
    using Yom.Template;

    public class BasePage
    {
        protected void SetCommon()
        {
            SkinTheme.SetLabel("Common.Keywords", SiteLoad.Scheme.KeyWords);
            SkinTheme.SetLabel("Common.Description", SiteLoad.Scheme.Description);
            SkinTheme.SetLabel("Common.SiteUrl", SiteLoad.Scheme.SiteUrl);
            SkinTheme.SetLabel("Common.Theme", SiteLoad.Scheme.Theme);
            SkinTheme.SetLabel("Common.SiteTitle", SiteLoad.Scheme.SiteTitle);
            SkinTheme.SetBlock("CategoryList", new Yom.Data.Category().GetCount());
            List<Yom.Model.Category> list = new Yom.Data.Category().GetList();
            int num = 0;
            foreach (Yom.Model.Category model in list)
            {
                SkinTheme.SetLabel(string.Format("CategoryList.SaveName_{0}", num), model.SaveName);
                SkinTheme.SetLabel(string.Format("CategoryList.Name_{0}", num), model.CategoryName);
                num++;
            }
            SkinTheme.SetLabel("Common.Ext", SiteLoad.Scheme.Ext);
            SkinTheme.SetLabel("Common.SaveFace", SiteLoad.Scheme.SaveFace);
            SkinTheme.SetLabel("Common.CopyRight", SiteLoad.Scheme.CopyRight.HtmlDeCode());
            SkinTheme.SetLabel("Common.BottomDesc", SiteLoad.Scheme.BottomDesc.HtmlDeCode());
        }

        protected void SetTopList()
        {
            List<Yom.Model.Comic> list = new Yom.Data.Comic().GetList("SELECT TOP 15 * FROM [Yom_Comic] WHERE [IsCheck]='True' ORDER BY [Visit] DESC");
            SkinTheme.SetBlock("TopList", list.Count);
            int num = 0;
            foreach (Yom.Model.Comic model in list)
            {
                int n = num + 1;
                SkinTheme.SetLabel(string.Format("TopList.Top_{0}", num), n.ToString());
                SkinTheme.SetLabel(string.Format("TopList.ID_{0}", num), n.ToString());
                SkinTheme.SetLabel(string.Format("TopList.SaveName_{0}", num), new Yom.Data.Category().GetModel(model.CategoryID).SaveName);
                SkinTheme.SetLabel(string.Format("TopList.TID_{0}", num), Math.Ceiling(Convert.ToDouble(model.ComicID) / 1000).ToString());
                SkinTheme.SetLabel(string.Format("TopList.CID_{0}", num), model.ComicID.ToString());
                SkinTheme.SetLabel(string.Format("TopList.Name_{0}", num), model.ComicName);
                SkinTheme.SetLabel(string.Format("TopList.Visit_{0}", num), model.Visit.ToString());
                num++;
            }
        }

        protected void SetRecommList()
        {
            List<Yom.Model.Comic> list = new Yom.Data.Comic().GetList("SELECT TOP 15 * FROM [Yom_Comic] WHERE [IsTop]='True' AND [IsCheck]='True' ORDER BY [Visit] DESC");
            SkinTheme.SetBlock("RecommList", list.Count);
            int num = 0;
            foreach (Yom.Model.Comic model in list)
            {
                SkinTheme.SetLabel(string.Format("RecommList.SaveName_{0}", num), new Yom.Data.Category().GetModel(model.CategoryID).SaveName);
                SkinTheme.SetLabel(string.Format("RecommList.CID_{0}", num), model.ComicID.ToString());
                SkinTheme.SetLabel(string.Format("RecommList.TID_{0}", num), Math.Ceiling(Convert.ToDouble(model.ComicID) / 1000).ToString());
                SkinTheme.SetLabel(string.Format("RecommList.FaceExt_{0}", num), model.FaceExt);
                SkinTheme.SetLabel(string.Format("RecommList.Name_{0}", num), model.ComicName);
                SkinTheme.SetLabel(string.Format("RecommList.LastName_{0}", num), new Yom.Data.Volume().GetLastVolume(model.ComicID).VolumeName);
                SkinTheme.SetLabel(string.Format("RecommList.State_{0}", num), new Yom.Data.Comic().GetState(model.State));
                num++;
            }
        }
    }
}